<%!
from flask import url_for
%>
<!DOCTYPE html>
<html lang="cn" charset="utf-8">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>${title}</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Bootstrap Icons -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
</head>
<body>
    <div class="container mt-5">
        <h1 class="mb-4">${heading}</h1>
        <p class="mb-4">${message}</p>

        % if error:
        <div class="alert alert-danger alert-dismissible fade show" role="alert">
            ${error}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        % endif

        % if success:
        <div class="alert alert-success alert-dismissible fade show" role="alert">
            ${success}
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
        % if tar_root_dir:
        <div class="text-center mb-4">
            <a href="${url_for('index.download', tar_root_dir=tar_root_dir, db_database=db_database)}" class="btn btn-primary">
                <i class="bi bi-download"></i> 下载生成的代码
            </a>
        </div>
        % endif
        % endif

        <div class="card">
            <div class="card-header">
                生成工程配置
            </div>
            <div class="card-body">
                <form method="POST" action="/generate">
                    <!-- 数据库配置 -->
                    <h5 class="mb-3">数据库配置</h5>
                    <div class="mb-3">
                        <label for="db_host" class="form-label">数据库主机</label>
                        <input type="text" class="form-control" id="db_host" name="db_host" value="www.nationaiot.com" required>
                    </div>
                    <div class="mb-3">
                        <label for="db_port" class="form-label">数据库端口</label>
                        <input type="number" class="form-control" id="db_port" name="db_port" value="23060" required>
                    </div>
                    <div class="mb-3">
                        <label for="db_database" class="form-label">数据库名</label>
                        <input type="text" class="form-control" id="db_database" name="db_database" value="db_enger" required>
                    </div>
                    <div class="mb-3">
                        <label for="db_user" class="form-label">数据库用户名</label>
                        <input type="text" class="form-control" id="db_user" name="db_user" value="root" required>
                    </div>
                    <div class="mb-3">
                        <label for="db_password" class="form-label">数据库密码</label>
                        <input type="password" class="form-control" id="db_password" name="db_password" value="root1234" required>
                    </div>

                    <!-- API配置 -->
                    <h5 class="mb-3 mt-4">API配置</h5>
                    <div class="mb-3">
                        <label for="api_host" class="form-label">API主机</label>
                        <input type="text" class="form-control" id="api_host" name="api_host" value="localhost" required>
                    </div>
                    <div class="mb-3">
                        <label for="api_port" class="form-label">API端口</label>
                        <input type="number" class="form-control" id="api_port" name="api_port" value="5005" required>
                    </div>
                    <div class="mb-3">
                        <label for="api_path" class="form-label">API路径</label>
                        <input type="text" class="form-control" id="api_path" name="api_path" value="/graphql" required>
                    </div>

                    <!-- 目标代码配置 -->
                    <h5 class="mb-3 mt-4">目标代码配置</h5>
                    <div class="mb-3">
                        <label for="tar_root_dir" class="form-label">目标代码根目录</label>
                        <input type="text" class="form-control" id="tar_root_dir" name="tar_root_dir" value="d:\dist\" required>
                    </div>
                    <div class="mb-3">
                        <label for="tar_ver" class="form-label">目标代码版本</label>
                        <input type="text" class="form-control" id="tar_ver" name="tar_ver" value="1.0.0" required>
                    </div>
                    <button type="submit" class="btn btn-primary">生成工程</button>
                </form>
            </div>
        </div>
    </div>

    <!-- Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>